<?php
namespace App\Utils;

trait Response
{
    protected function httpJson($data,$code)
    {

        return response()->json($data,$code)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
    }

    protected function httpSuccess($data = null, $message = "操作成功", $code = 200)
    {
        $data = compact("data","code","message");
        return $this->httpJson($data,$code);
    }

    protected function httpError($message = "操作失败", $code = 400,$data = null,$hcode = 200)
    {
        $data = compact("data","code","message");
        return $this->httpJson($data,$hcode);
    }
}